package com.api.apiinterface.controller;

import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/name")
/**
 * 测试controller类，输入username返回输入的用户的信息
 */
public class NameController {
    /**
     * 使用get方法获取姓名
     * @param name
     * @param request
     * @return
     */
    @GetMapping("/get")
    public Map<String,String> getNameByGet(@RequestParam String name, HttpServletRequest request){
        Map<String,String> res = new HashMap<>();
        res.put("text","GET 您的名字是"+ name);
        return res;
    }
    @PostMapping("/post")
    public Map<String,String> getNameByPost(@RequestBody String name, HttpServletRequest request){
        Map<String,String> res = new HashMap<>();
        res.put("text","post 您的名字是"+ name);
        return res;
    }
}
